package com.yiren.dbaa.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.widget.RelativeLayout;

/**
 * Created by WANGRONGXIANG
 * on 2020/12/15
 * Describe
 */
public class MapRelativeLayout extends RelativeLayout {

    private int width;
    private int height;
    private int screenWidth;
    private int screenHeight;

    private OnOUtScreenClickListener listener;

    public void setListener(OnOUtScreenClickListener listener) {
        this.listener = listener;
    }

    public MapRelativeLayout(Context context) {
        this(context, null);
    }

    public MapRelativeLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MapRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        getScreenWidth();
    }

    /**
     * 得到屏幕宽度
     *
     * @return
     */
    private void getScreenWidth() {
        WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        windowManager.getDefaultDisplay().getMetrics(displayMetrics);
        screenWidth = displayMetrics.widthPixels;
        screenHeight = displayMetrics.heightPixels;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return false;
    }

    private float moveX;
    private float moveY;
    int l, r, t, b;

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        width = getWidth();
        height = getHeight();
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
//                listener.onOutScreen();
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_UP:
                break;
        }
        return false;
    }

    public interface OnOUtScreenClickListener {
        void onOutScreen();
    }

}
